# 无参数的装饰器
# def test(func):
#     print("======1====")
#     def inner():
#         print("===inner-1===")
#         func()
#         print("===inner-2===")
#     return inner
#
# @test
# def w1():
#     print("======w1======")
#
# w1()

# 有2个数的装饰器
def test2(funcName):
    print("=====1======")
    def inner(a,b):# 此处定义的参数和原函数的参数个数保持一致
        print("=====inner1====")
        funcName(a,b)
        print("=====inner2====")
    return inner

# 有不定长参数的情况的装饰器
def test3(funcName):
    print("====3======")
    def inner(*args,**kwargs):
        print("----inner1---")
        funcName(*args,**kwargs)
        print("----inner2---")
    return inner

@test3
def w2(a,b,c):
    print("%d+%d+%d=%d"%(a,b,c,a+b+c))

w2(3,4,5)
@test3
def w3(a,b,c,d):
    print("%d+%d+%d+%d=%d"%(a,b,c,d,a+b+c+d))

w3(3,4,5,6)

